]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
mixer-control: Simplify device lookup
authorGuido Günther <agx@sigxcpu.org>
Mon, 5 Jan 2026 16:15:40 +0000 (17:15 +0100)
committerSimon McVittie <smcv@debian.org>
Wed, 28 Jan 2026 13:25:18 +0000 (13:25 +0000)
There were too branches, one for portless streams (called "network
streams" here) and those with ports. The portless one checked the
stream-id only while the other branch checked stream-id and port.

Simplify this by checking the stream-id and only comparing ports when
available.

As other streams can be portless nowadays this also removes some
confusion.

Best reviewed with 'git show -w'

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Origin: https://gitlab.gnome.org/GNOME/libgnome-volume-control/-/merge_requests/31
Bug: https://gitlab.gnome.org/GNOME/libgnome-volume-control/-/issues/34
Bug-Debian: https://bugs.debian.org/1126514
Applied-upstream: gnome-shell 50, commit:798230599950607ec285daecd070f5bcb28580e4

Gbp-Pq: Topic libgvc
Gbp-Pq: Name mixer-control-Simplify-device-lookup.patch

subprojects/gvc/gvc-mixer-control.c

index 251f78a240426d217282b0e1f78988d3422f076f..a8c75a06287e35e459e44a9218827775b1463603 100644 (file)
@@ -239,7 +239,6 @@ gvc_mixer_control_lookup_device_from_stream (GvcMixerControl *control,
                                              GvcMixerStream *stream)
 {
         GList                   *devices, *d;
-        gboolean                 is_network_stream;
         const GList             *ports;
         GvcMixerUIDevice        *ret;
 
@@ -253,39 +252,38 @@ gvc_mixer_control_lookup_device_from_stream (GvcMixerControl *control,
 
         ret = NULL;
         ports = gvc_mixer_stream_get_ports (stream);
-        is_network_stream = (ports == NULL);
 
         for (d = devices; d != NULL; d = d->next) {
                 GvcMixerUIDevice *device = d->data;
                 guint stream_id = G_MAXUINT;
+                const GvcMixerStreamPort *port;
 
                 g_object_get (G_OBJECT (device),
                              "stream-id", &stream_id,
                               NULL);
 
-                if (is_network_stream &&
-                    stream_id == gvc_mixer_stream_get_id (stream)) {
-                        g_debug ("lookup-device-from-stream - %s - it is a network_stream ",
+                if (stream_id != gvc_mixer_stream_get_id (stream))
+                        continue;
+
+                if (ports == NULL) {
+                        g_debug ("lookup-device-from-stream - %s - is portless ",
                                  gvc_mixer_ui_device_get_description (device));
                         ret = device;
                         break;
-                } else if (!is_network_stream) {
-                        const GvcMixerStreamPort *port;
-                        port = gvc_mixer_stream_get_port (stream);
-
-                        if (stream_id == gvc_mixer_stream_get_id (stream) &&
-                            g_strcmp0 (gvc_mixer_ui_device_get_port (device),
-                                       port->port) == 0) {
-                                g_debug ("lookup-device-from-stream found device: device description '%s', device port = '%s', device stream id %i AND stream port = '%s' stream id '%u' and stream description '%s'",
-                                         gvc_mixer_ui_device_get_description (device),
-                                         gvc_mixer_ui_device_get_port (device),
-                                         stream_id,
-                                         port->port,
-                                         gvc_mixer_stream_get_id (stream),
-                                         gvc_mixer_stream_get_description (stream));
-                                ret = device;
-                                break;
-                        }
+                }
+
+                port = gvc_mixer_stream_get_port (stream);
+                if (g_strcmp0 (gvc_mixer_ui_device_get_port (device), port->port) == 0) {
+                        g_debug ("lookup-device-from-stream found device: device description '%s', device port = '%s', device stream id %i AND stream port = '%s' stream id '%u' and stream description '%s'",
+                                 gvc_mixer_ui_device_get_description (device),
+                                 gvc_mixer_ui_device_get_port (device),
+                                 stream_id,
+                                 port->port,
+                                 gvc_mixer_stream_get_id (stream),
+                                 gvc_mixer_stream_get_description (stream));
+                        ret = device;
+                        break;
+
                 }
         }